package com.java.service.impl;

import com.java.mapper.HouseMapper;
import com.java.mapper.InRoomMapper;
import com.java.mapper.OrderMapper;
import com.java.pojo.InRoomInfoBean;
import com.java.service.InRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @function:
 * @CreateTime: 2021/3/16 22:45
 */
@Service
public class InRoomServiceImpl implements InRoomService {
    @Autowired
    private InRoomMapper inRoomMapper;

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private HouseMapper houseMapper;
    public List<Map<String, Object>> getInRoomInfo(String customerName, String idcard, String phone, String roomnum) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("customerName", customerName);
        map.put("idcard", idcard);
        map.put("phone", phone);
        map.put("roomnum", roomnum);
        return inRoomMapper.getInRoomInfo(map);
    }

    public boolean insertInRoomInfo(InRoomInfoBean inRoomInfoBean) {
        int res = inRoomMapper.insertInRoomInfo(inRoomInfoBean);
        int rs1 = houseMapper.updateRoomBystatus("1", inRoomInfoBean.getRoomId());
        return res >= 1 && rs1 >=1? true : false;
    }

    @Override
    public List<Map<String, Object>> getOrderInfo() {
        return orderMapper.getOrderInfo(new HashMap<String, Object>());
    }
}
